<template>
  <zh-form-card title="基本信息" :span="24">
    <zh-form ref="formRef" :model="data.formData" label-width="200px" :span="12" :rules="data.rules">
            <zh-form-input
          prop="batchNo"
          label="批次号"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.batchNo"
      ></zh-form-input>
      <zh-form-input
          prop="personId"
          label="学生人员id"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.personId"
      ></zh-form-input>
      <zh-form-input
          prop="idcard"
          label="学生身份证"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.idcard"
      ></zh-form-input>
      <zh-form-input
          prop="fullName"
          label="学生"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fullName"
      ></zh-form-input>
      <zh-form-input
          prop="cardType"
          label="学生证件类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.cardType"
      ></zh-form-input>
      <zh-form-input
          prop="birthYmd"
          label="出生日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.birthYmd"
      ></zh-form-input>
      <zh-form-input
          prop="sex"
          label="性别"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.sex"
      ></zh-form-input>
      <zh-form-input
          prop="age"
          label="学生年龄"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.age"
      ></zh-form-input>
      <zh-form-input
          prop="submitterId"
          label="提交人员userId"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.submitterId"
      ></zh-form-input>
      <zh-form-input
          prop="submitterName"
          label="提交人员姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.submitterName"
      ></zh-form-input>
      <zh-form-input
          prop="orgId"
          label="提交人员所属组织"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.orgId"
      ></zh-form-input>
      <zh-form-input
          prop="telphone"
          label="提交人员联系电话"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.telphone"
      ></zh-form-input>
      <zh-form-input
          prop="remarks"
          label="备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.remarks"
      ></zh-form-input>
      <zh-form-input
          prop="address"
          label="现居住地址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.address"
      ></zh-form-input>
      <zh-form-input
          prop="householdPlace"
          label="户籍地"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householdPlace"
      ></zh-form-input>
      <zh-form-input
          prop="fatherId"
          label="父亲id"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherId"
      ></zh-form-input>
      <zh-form-input
          prop="fatherName"
          label="父亲姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherName"
      ></zh-form-input>
      <zh-form-input
          prop="fatherCardType"
          label="父亲（监护人）证件类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherCardType"
      ></zh-form-input>
      <zh-form-input
          prop="fatherIdcard"
          label="父亲身份证"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherIdcard"
      ></zh-form-input>
      <zh-form-input
          prop="fatherWork"
          label="父亲工作"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherWork"
      ></zh-form-input>
      <zh-form-input
          prop="fatherCellphone"
          label="父亲手机"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fatherCellphone"
      ></zh-form-input>
      <zh-form-input
          prop="motherId"
          label="母亲id"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherId"
      ></zh-form-input>
      <zh-form-input
          prop="motherName"
          label="母亲姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherName"
      ></zh-form-input>
      <zh-form-input
          prop="motherCardType"
          label="母亲证件类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherCardType"
      ></zh-form-input>
      <zh-form-input
          prop="motherIdcard"
          label="母亲身份证"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherIdcard"
      ></zh-form-input>
      <zh-form-input
          prop="motherWork"
          label="母亲工作"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherWork"
      ></zh-form-input>
      <zh-form-input
          prop="motherCellphone"
          label="母亲手机"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.motherCellphone"
      ></zh-form-input>
      <zh-form-input
          prop="enrollPreType"
          label="预采集类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.enrollPreType"
      ></zh-form-input>
      <zh-form-input
          prop="schoolId"
          label="学校"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.schoolId"
      ></zh-form-input>
      <zh-form-input
          prop="shortName"
          label="学校简称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.shortName"
      ></zh-form-input>
      <zh-form-input
          prop="schoolCategory"
          label="学段"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.schoolCategory"
      ></zh-form-input>
      <zh-form-input
          prop="type"
          label="数据类型(insert,update)"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.type"
      ></zh-form-input>
      <zh-form-input
          prop="year"
          label="年份"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.year"
      ></zh-form-input>
      <zh-form-input
          prop="fileInfo"
          label="材料信息"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fileInfo"
      ></zh-form-input>
      <zh-form-input
          prop="areaCode"
          label="行政区划"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.areaCode"
      ></zh-form-input>
      <zh-form-input
          prop="houseSyncFlag"
          label="房产同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.houseSyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="houseSyncRemark"
          label="房产同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.houseSyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="householdSyncFlag"
          label="户籍同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householdSyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="householdSyncRemark"
          label="户籍同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householdSyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="netsignSyncFlag"
          label="网签同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.netsignSyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="netsignSyncRemark"
          label="网签同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.netsignSyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="cbSyncFlag"
          label="参保同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.cbSyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="cbSyncRemark"
          label="参保同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.cbSyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="qySyncFlag"
          label="开办企业同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qySyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="qySyncRemark"
          label="开办企业同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qySyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="jzzSyncFlag"
          label="居住证同步状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.jzzSyncFlag"
      ></zh-form-input>
      <zh-form-input
          prop="jzzSyncRemark"
          label="居住证同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.jzzSyncRemark"
      ></zh-form-input>
      <zh-form-input
          prop="beforeFlag"
          label="预报名同步标识"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.beforeFlag"
      ></zh-form-input>
      <zh-form-input
          prop="beforeRemark"
          label="预报名同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.beforeRemark"
      ></zh-form-input>
      <zh-form-input
          prop="busNo"
          label="流水号"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.busNo"
      ></zh-form-input>
      <zh-form-input
          prop="authStatus"
          label="审核状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.authStatus"
      ></zh-form-input>
      <zh-form-input
          prop="authRemarks"
          label="审核意见"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.authRemarks"
      ></zh-form-input>
      <zh-form-date
          prop="authTime"
          label="审核时间"
          type="datetime"
          :disabled="props.disabled"
          v-model="data.formData.authTime"
          :span="8"
      ></zh-form-date>
      <zh-form-input
          prop="authUserId"
          label="审核人"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.authUserId"
      ></zh-form-input>
      <zh-form-input
          prop="familyFlag"
          label="出生证比对状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.familyFlag"
      ></zh-form-input>
      <zh-form-input
          prop="familyType"
          label="家庭关系比对类型1 大数据比对 2 人工核对"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.familyType"
      ></zh-form-input>
      <zh-form-input
          prop="familyRemark"
          label="出生证比对备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.familyRemark"
      ></zh-form-input>
      <zh-form-input
          prop="calculateFlag"
          label="预测比对情况"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.calculateFlag"
      ></zh-form-input>
      <zh-form-input
          prop="calculateRemark"
          label="预测同步备注"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.calculateRemark"
      ></zh-form-input>
      <zh-form-input
          prop="followingFlag"
          label="是否非随迁子女 0 否 1 是"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.followingFlag"
      ></zh-form-input>
      <zh-form-input
          prop="consistentFlag"
          label="是否房户一致 0 未比对 1比对通过 2比对不通过"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.consistentFlag"
      ></zh-form-input>
      <zh-form-input
          prop="aborigineFlag"
          label="是否原住民"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.aborigineFlag"
      ></zh-form-input>
      <zh-form-input
          prop="consistentType"
          label="房户一致比对类型：1 大数据比对 2 人工核对"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.consistentType"
      ></zh-form-input>
      <zh-form-input
          prop="consistentRemarks"
          label="一致情况说明"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.consistentRemarks"
      ></zh-form-input>
      <zh-form-input
          prop="consistentUserId"
          label="房产一致人工操作人"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.consistentUserId"
      ></zh-form-input>
      <zh-form-date
          prop="consistentTime"
          label="房产一致性处理时间"
          type="datetime"
          :disabled="props.disabled"
          v-model="data.formData.consistentTime"
          :span="8"
      ></zh-form-date>
      <zh-form-input
          prop="houseId"
          label="房产id"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.houseId"
      ></zh-form-input>
      <zh-form-input
          prop="householdId"
          label="户籍id"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householdId"
      ></zh-form-input>
      <zh-form-input
          prop="serviceAreaFlag"
          label="是否服务区 0 否 1是"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.serviceAreaFlag"
      ></zh-form-input>
      <zh-form-input
          prop="agentEnrollFlag"
          label="代理报名：0 否 1是，代理报名将不控制房产等所有人"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.agentEnrollFlag"
      ></zh-form-input>
    </zh-form>
  </zh-form-card>
</template>

<script lang="ts" setup name="eduStudentEnrollPreOfflineForm">
import { ElMessage } from 'element-plus';

//------------------定义子组件---------------------------
const formRef = ref();
//------------------接收传入参数(组件)-------------------
const props = defineProps({
  studentEnrollPreId: {
    type: String,
    default: '',
  },
  disabled: {
    type: Boolean,
    default: true,
  },
  btnLoding: Boolean,
});
const emits = defineEmits(['update:btnLoding', 'canner', 'refreshTable']);
//------------------初始化------------------------------
onMounted(() => {
  getDict();
  getsurveyInfo();
});
//------------------内部变量定义-------------------------
const data = reactive({
  formData: {} as any,
  detailVisible: true,
  loading: false,
  rules: {
  },
  dictData: {} as any,
  areaCodeDict: [] as any,
  campusParam: {} as any,
});

// 查询数据字典信息
const getDict = () => {
  const params = {} as any;
  params.dictFields = '';
  $api.common.getBatchDict.post(params).then((res) => {
    data.dictData = res.result;
  });
};

//获取详情
const getsurveyInfo = () => {
  if (!props.studentEnrollPreId) {
    return;
  }
  data.loading = true;
  $api.common.send
  .post('eduStudentEnrollPreOffline0002', { studentEnrollPreId: props.studentEnrollPreId })
  .then((res: any) => {
    data.formData = res.result || {};
    data.loading = false;
    data.campusParam.schoolId = data.formData.schoolId;
  })
  .catch(() => {
    data.loading = false;
  });
};

//保存
async function saveBase() {
  let checkFlag = await formRef.value.checkForm();
  if (checkFlag) {
    if (data.formData.studentEnrollPreId) {
      $api.common.send
      .post('eduStudentEnrollPreOffline0005', data.formData)
      .then(() => {
        ElMessage.success('修改成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    } else {
      $api.common.send
      .post('eduStudentEnrollPreOffline0004', data.formData)
      .then(() => {
        ElMessage.success('新增成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    }
  }
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({ saveBase });
</script>
<style lang="scss" scoped></style>
